package de.koo.grum.domain

class User {
   String username
   String password
   String firstname
   String lastname
   Date createdAt
   String imagename
   Address address

   static belongsTo = Group
   static hasMany = [groups:Group,contactData:ContactData]
   
   static mapping = {
	      table 'tbl_users'
	  }

   static constraints = {
        username(size:2..10,blank:false,unique:true)
        password(size:3..10,blank:false)
        firstname(nullable:true)
        createdAt(nullable:true)
        imagename(nullable:true)
    }
    
    def beforeInsert = {
	   createdAt = new Date()
    }
    
    String toString() {"${this.username}: ${this.firstname} ${this.lastname}"}
}